const { app } = require('electron');
const path = require('path');
const nconf = require('nconf');

const logger = require('./utils/logger');

const userDataDir = app.getPath('userData');
const pathConfigFile = path.join(userDataDir, 'config.json');

nconf.argv().env();
try {
    nconf.file({
        file: pathConfigFile,
    });
} catch (error) {
    logger.error('Please correct the mistakes in your configuration file: [%s].\n' + error, pathConfigFile);
}

module.exports = nconf;
